package org.example.struct.array;

/**
 * @author liyishan
 * @date 2023/8/22 11:08
 * @apiNote
 */

public class Test01170NumSmallerByFrequency {
    public static void main(String[] args) {

    }

    public static int[] test(String[] queries, String[] words) {
        int n = queries.length;
        int m = words.length;
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            int count = 0;
            int size = f(queries[i]);
            for (int j = 0; j < m; j++) {
                if(f(words[j]) > size){
                    count++;
                }
            }
            res[i] = count;
        }
        return res;
    }

    public static int f(String s) {
        int[] count = new int[26];
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            count[c - 'a']++;
        }
        int min = 0;
        for (int i = 0; i < 26; i++) {
            if (count[i] != 0) {
                min = count[i];
                return min;
            }
        }
        return 0;
    }
}
